﻿using Microsoft.Extensions.DependencyInjection;
using Microsoft.Extensions.Hosting;
using Serilog;
using Serilog.Events;

namespace ConsoleApp1
{
    internal class Program
    {
        static async Task Main(string[] args)
        {
            Log.Logger = new LoggerConfiguration()
                .WriteTo.File(
                    path: "logs/logs.txt",
                    rollingInterval: RollingInterval.Day,
                    rollOnFileSizeLimit: false,
                    flushToDiskInterval: TimeSpan.FromSeconds(2))
                .WriteTo.Console()
                .CreateLogger();

            var host = Host.CreateDefaultBuilder(args)
                .ConfigureServices((context, services) =>
                {
                    services.AddHostedService<BackgroundWork>();
                })
                .UseSerilog()
                .UseWindowsService()
                .Build();

            await host.RunAsync();
        }
    }
}